<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Appmodules {
    var $id;
    var $module_name;
    var $title;
    var $description;
    var $url_icon;
    var $enabled;

    function __construct($id,$module_name,$title,$description,$url_icon,$enabled) {
            
        $this->id=$id; 
        $this->module_name=$module_name;
        $this->title=$title;
        $this->description=$description;
        $this->url_icon=$url_icon;
        $this->enabled=$enabled;
    }
    function open(){
        global $db;
        $sql="select * from app_modules where id=$id";
        $row=$db->fetch_row($sql);
        if (!empty($row)){
            extract($row);
            $this->module_name=$module_name;
            $this->title=$title;
            $this->description=$description;
            $this->url_icon=$url_icon;
            $this->enabled=$enabled;

        }
    }

    function openAll(){
        $sql="select * from app_modules order by id asc";
        $result=$db->query($sql);
        return $db->fetch_array($result);
        
    }

    function insert(){
    global $db;
    $sql="insert into app_modules values (null,'{$this->module_name}',
    '{$this->title}','{$this->description}','{$this->url_icon}','{$this->enabled}')";
    $db->query($sql);
    return mysql_insert_id();
    }

    function update(){
        global $db;
        $sql="update app_modules set module_name='{$this->module_name}',
title='{$this->title}',description='{$this->description}',url_icon='{$this->url_icon}',
enabled='{$this->enabled}' where id=".$this->id;
        $db->query($sql);
    }

    function delete(){
        global $db;
        $sql="delete from app_modules where id=".$this->id;
        $db->query($sql);
    }

}
?>
